/*
 * testScenarioElement.h
 *
 *  Created on: Sep 24, 2011
 *      Author: nicoabie
 */

#ifndef TESTSCENARIOELEMENT_H_
#define TESTSCENARIOELEMENT_H_

#include "../src/SDLtoolkit/ScenarioElement.h"
#include <iostream>

using namespace std;

void testScenarioElement() {

	Surface* screen;
	screen = new Surface(new SDL_Surface());

	std::string screenTitle = "ventana";
	if (SDL_Init(SDL_INIT_EVERYTHING) == -1) {
		cout << "No se pudo iniciar la SDL" << endl;
	}

	if (TTF_Init() == -1) {
		cout << "No se pudo iniciar la TTF" << endl;
	}

	screen->SetVideoMode(800, 600, 24, SDL_SWSURFACE);
	if (screen == NULL) {
		cout << "No se pudo iniciar la superficie principal" << endl;
	}

	SDL_WM_SetCaption(screenTitle.c_str(), NULL);
	SDL_FillRect(screen->getSurface(), &screen->getSurface()->clip_rect,
			SDL_MapRGB(screen->getSurface()->format, 233, 233, 233));

	ScenarioElement* elementoEscenario = new ScenarioElement(50,50, &screen,"./res/img/dot.bmp");

	Event* eventoloco = new Event();

	bool quit = false;
	SDL_Event event;
	while (quit == false) {
		while (SDL_PollEvent(&event)) {
			eventoloco->setEvent(event);

			SDL_FillRect( screen->getSurface(), &(screen->getSurface()->clip_rect), SDL_MapRGB( screen->getSurface()->format, 0xFF, 0xFF, 0xFF ) );

			elementoEscenario->handleEvent(*eventoloco);
			elementoEscenario->draw();

			SDL_Flip(screen->getSurface());
			if (eventoloco->getType() == Quit) {
				quit = true;
			}
		}
	}
	delete(screen);
	delete(elementoEscenario);
	SDL_Quit();
}



#endif /* TESTSCENARIOELEMENT_H_ */
